package ch.headshot.photomap.client.gpx.impl;

import java.util.ArrayList;
import java.util.List;

import ch.headshot.photomap.client.gpx.Route;
import ch.headshot.photomap.client.gpx.WayPoint;

import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.NodeList;

public class RouteImpl implements Route {

	private static final String RTEPT = "rtept";
	private final Element item;

	public RouteImpl(Element item) {
		this.item = item;
	}

	public List<WayPoint> getPoints() {
		List<WayPoint> result = new ArrayList<WayPoint>();
		NodeList rtes = item.getElementsByTagName(RTEPT);
		for (int i = 0; i < rtes.getLength(); i++) {
			result.add(new WayPointImpl((Element) rtes.item(i)));
		}
		return result;
	}

}
